<template>
	<view class="content">
		<view class="top p20 line18 f28">
			<view class="mb20">
				可提现(元)
				<view class="f34 clo-fff">{{commission.money}}</view>
			</view>
			<view class="dis_cc">
				<view class="w100 ">
					总佣金(元)
					<view class="f34 clo-fff">{{commission.all}}</view>
				</view>
				<view class="w100 ">
					已提现佣金(元)
					<view class="f34 clo-fff">{{commission.already}}</view>
				</view>
			</view>
			<button class="pa bgfff line18 clo-blue f28 pl20 pr20" @click="tapLink('/pages/index/addWithdrawal')">去提现</button>
		</view>
		<view class="tit p20 ml20 f34 line2">提现记录</view>
		<view class="main" v-if="list.length > 0">
			<view v-for="(item,index) in list" class="dis_sb bgfff pl20 pr20 line18 bb1 pb10 pt10">
				<view class="shrink">
					<view>提现金额：<text class="clo-blue f34">{{item.uw_money}}</text>元</view>
					<view class="clo-999 f28">提现日期：{{item.re_create}}</view>
				</view>
				<view class="clo-green" v-if="item.uw_examine_type == 1 && item.uw_state == 1">提现成功</view>
				<view class="clo-orange" v-else-if="item.uw_examine_type == 0">提现中</view>
				<view class="clo-orange" v-else-if="item.uw_examine_type == 2">提现拒绝</view>
				<view class="clo-orange" v-else-if="item.uw_examine_type == 1 && item.uw_state == 0">提现中</view>
				<view class="clo-orange" v-else-if="item.uw_examine_type == 1 && item.uw_state == 2">提现失败</view>
			</view>
		</view>
		<div class="listdata_desc" v-if="list.length > 0 && listdata_desc != ''">{{ listdata_desc }}</div>
		<template v-if="list.length == 0">
		    <div class="empty_box acea-row row-center-wrapper">
		        <div>
		            <div class="empty_icon">
		                <image class="img" src="/static/icon_null.png" mode="aspectFill"></image>
		            </div>
		            <div class="empty_msg">暂无数据</div>
		        </div>
		    </div>
		</template>
	</view>
</template>

<script>
	import {userWithdrawal} from '@/utils/api.js'
	export default {
		data() {
			return {
				commission:{
					money:'0',
					all:'0',
					already:'0'
				},
				is_more:true,
				listdata_desc:'',
				list:[],
				searchFrom: {
					page: 1,
					pageSize: 20
				}
			}
		},
		//监听滑动到底部
		onReachBottom() {
			if (this.is_more) {
			    this.searchFrom.page++;
			    this.get_list();
			}
		},
		onShow() {
			this.list = [];
			this.is_more = true;
			this.listdata_desc = '';
			this.searchFrom.page = 1;
			this.get_list();
		},
		methods: {
			tapLink(e){
				uni.navigateTo({
					url:e
				})
			},
			get_list(){
				this.listdata_desc = '正在加载';
				userWithdrawal(this.searchFrom).then(res=>{
					let list = res.data.list
					this.commission.money = res.data.use_balance;
					this.commission.all = res.data.total_money;
					this.commission.already = res.data.stop_balance;
					if(this.page == 1){
					    this.is_more = true;
					    this.list = [];
					}
					
					this.listdata_desc = '';
					if (list.length == 0) {
					    //阻止继续分页
					    this.is_more = false;
					    this.listdata_desc = '没有更多了';
					    return;
					}
					if (list.length < this.pageSize) {
					    this.is_more = false;
					    this.listdata_desc = '没有更多了';
					}
					if(list.length > 0){
						list.forEach(item=>{
							this.list.push(item)
						})
					}
				})
			}
		}
	}
</script>

<style>
	
	.top {background: linear-gradient(#3172f9, #6193fc); }
	
	.main {height: 67vh; overflow-y: auto;}
	.top {color: rgba(255,255,255,0.6)!important; position: relative;}
	.pa {top: 20%; right: 5%;}
	 
	 .clo-green,.clo-orange {width: 30%; text-align: right;}
</style>
